//
//  SXFeedBackViewController.m
//  ShiXun
//
//  Created by lanou on 15/11/4.
//  Copyright © 2015年 张琪. All rights reserved.
//

#import "SXFeedBackViewController.h"
#import "SXFeedBackView.h"
@interface SXFeedBackViewController ()<UITextViewDelegate, UITextFieldDelegate>
@property(nonatomic, strong)SXFeedBackView *feedBackView;
@end

@implementation SXFeedBackViewController
- (SXFeedBackView *)feedBackView
{
    if (_feedBackView == nil) {
        _feedBackView = [[SXFeedBackView alloc] initWithFrame:self.view.bounds];
        _feedBackView.messageText.delegate = self;
        _feedBackView.numberText.delegate = self;
        [_feedBackView.referButton addTarget:self action:@selector(didClickButton) forControlEvents:UIControlEventTouchUpInside];
    }
    return _feedBackView;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationItem.title = @"意见反馈";
    self.navigationController.navigationBar.hidden = NO;
    [self.view addSubview:self.feedBackView];
    // Do any additional setup after loading the view.
}
- (void)textViewDidChange:(UITextView *)textView
{
    if (textView.text.length != 0) {
        self.feedBackView.placeLabel.text = @"";
    }else
    {
        self.feedBackView.placeLabel.text = @"请输入反馈信息";
    }
}
- (void)didClickButton
{
    UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"提交成功" message:@"感谢您留下的宝贵意见！" preferredStyle:UIAlertControllerStyleAlert];
    UIAlertAction *sureAct = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
        [self.navigationController popViewControllerAnimated:YES];
    }];
    [alertController addAction:sureAct];
    [self presentViewController:alertController animated:YES completion:nil];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
    [textField resignFirstResponder];
    return YES;
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
